#include <iostream>
#include <memory>
#include "udp_socket.hpp"
#include "dict.hpp"

std::string ToUpper(const std::string &msg)
{
    std::string ret = "hello";
    ret += msg;
    return ret;
}

int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        std::cout << "Usage: ./udp_server <IP> <PORT>" << std::endl;
        return 1;
    }
    uint16_t port = static_cast<uint16_t>(std::stoi(argv[1]));
    //  std::string ip = argv[1];

    Enable_Console_Log_Strategy();

    // 字典对象
    Dict dict;
    dict.Load();
    // std::unique_ptr<Dict> dict_ptr = std::make_unique<Dict>(dict);
    // 网络服务器对象

    std::unique_ptr<UDPServer> server = std::make_unique<UDPServer>(port, [&dict](const std::string &msg) -> std::string
                                                                    {
                                                                        return dict.Translate(msg);
                                                                    });
    server->init();
    server->start();

    return 0;
}
